package day12.DuiXiang.ZongHe;

import java.io.*;
import java.util.TreeSet;

public class Text {
    public static void main(String[] args) throws IOException {
        TreeSet<Person> list = new TreeSet<>();
        BufferedReader br = new BufferedReader(new FileReader("H:\\itheima\\aa\\person.txt"));
        String s;
        while ((s = br.readLine()) != null) {
            String[] split = s.split(",");
            String name = split[0];
            String gender = split[1];
            int age = Integer.parseInt(split[2]);
            Person p = new Person(name, gender, age);
            list.add(p);
        }
        br.close();
        BufferedWriter bw = new BufferedWriter(new FileWriter("H:\\itheima\\bb\\person.txt"));
        for (Person person : list) {
            bw.write(person.getName() + "," + person.getGender() + "," + person.getAge());
            bw.newLine();
            bw.flush();
        }
        bw.close();
    }
}
